<?php
header("Access-Control-Allow-origin:*");
$ukey=$_POST["ukey"];
$level=$_POST["level"] ? $_POST["level"] :2;
$arr=[];

$page = $_POST["page"] ? $_POST["page"] : 1;
$pagesize = $_POST["pagesize"] ? $_POST["pagesize"] : 20;
$arr = [];
$resArr = [];
$start = ($page - 1) * $pagesize + 1;
$end = $page * $pagesize;

if ($page == 5) {
    $end = $page * $pagesize - 5;
}

$randon=1;

if(!$ukey){
	$arr["code"]=308;
	$arr["msg"]="请您先登录！";
	$arr["data"]=array();
}else{
	$arr["code"]=200;
	$arr["data"]["peoples"]=6000;
	$arr["data"]["commission"]=98989;

	$terms=array();
	//邀请人是自己
	
	if($level==2){
		if(!!$randon){
			for ($i = $start; $i <= $end; $i++) {
		        $terms[] = array(
		            "realname" => "2级用户".$i,
		            "commission" => "+".$i,
		        );

		    }
		}
	}else{
		if(!!$randon){
			for ($i = $start; $i <= $end; $i++) {
		        $terms[] = array(
		            "realname" => "3级用户".$i,
		            "invitename" => "邀请人".$i,
		            "commission" => $i,
		        );

		    }
		}
	}
	$arr["data"]["terms"]=$terms;	
}

echo json_encode($arr);
?>